import React, { useState } from "react";
import B from "./B";
//1. 创建并暴露 context 对象
export let Context = React.createContext();

export default function A() {
  //
  let msg = "多巴胺不等于爱情，爱情却一定有多巴胺";
  let style = {color: 'rgb(10,20,150)'};
  let [count, setCount] = useState(100);
  return (
    <div>
      <div>A</div>
      <hr />
      {/* 2. 使用 Context.Provider 包裹子节点 */}
      <Context.Provider value={{msg, style, count, setCount}}>
        <B />
      </Context.Provider>
    </div>
  );
}
